/*
 * The Smacker library was ported from C# for use in Silvie. The original
 * library is copyright Chris Toshok. It is released under an X11 license.
 */

package utils.smacker;

public class SmackerHeader {
	/* Smacker file header */
	public int signature;
	public int width, height;
	public int nbFrames;
	public int ptsInc;
	public double fps;
	public int flags;
	public int[] audioSize = new int[7];
	public int treesSize;
	public int nMapSize;
	public int mClrSize;
	public int fullSize;
	public int typeSize;
	public int[] audioRate = new int[7];
	public int dummy;

	/**
	 * Returns the sample rate for the specified audio track
	 * 
	 * @param i the audio track to return the sample rate for
	 * @return The sample rate for track i
	 */
	public int getSampleRate(int i) {
		// Mask out the upper byte
		return this.audioRate[i] & 0xFFFFFF;
	}

	public boolean isStereoTrack(int i) {
		return ((this.audioRate[i] >> 24) & 16) > 0;
	}

	public boolean is16BitTrack(int i) {
		return ((this.audioRate[i] >> 24) & 32) > 0;
	}

	public boolean isCompressedTrack(int i) {
		return ((this.audioRate[i] >> 24) & 128) > 0;
	}

	public boolean hasRingFrame() {
		return (this.flags & 1) > 0;
	}

	public boolean isYInterlaced() {
		return (this.flags & 2) > 0;
	}

	public boolean isYDoubled() {
		return (this.flags & 4) > 0;
	}
}
